package jd;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class sushu {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        Deque<Integer> deque = new ArrayDeque<>();
        deque.addLast(2);
        deque.addLast(3);
        deque.addLast(5);
        int val = 0;
        while(!deque.isEmpty()){
            Integer integer = deque.pollFirst();
            val++;
            if(val==n){
                System.out.println(integer);
                return;
            }
            deque.addLast(integer*10 + 2);
            deque.addLast(integer*10 + 3);
            deque.addLast(integer*10 + 5);
        }

    }
}
